document.write('<script type="text/javascript" src="../js/error/js/ns-window.js"></script>');
document.write('<link href="../js/error/css/dreamstu.css" rel="stylesheet" type="text/css" />');
document.write('<link href="../js/error/css/errPage.css" rel="stylesheet" type="text/css" />');

var win =null;//window object
/*
function getRootPath(){
    //获取当前网址
    var curWwwPath=window.document.location.href;
    //获取主机地址之后的目录
    var pathName=window.document.location.pathname;
    var pos=curWwwPath.indexOf(pathName);
    //获取主机地址
    var localhostPaht=curWwwPath.substring(0,pos);
    //获取带"/"的项目名，如：/BtrWeb
    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
    return(localhostPaht+projectName+"/");
}*/

/**
 * 掉线
 */
function loginLoseError(){
	win = $.nsWindow.open({
		title: '您的账户会话已过期...',
		width: 305,
		height: 205,
		showControlBar:true,
		dataUrl: getRootPath()+'js/error/loginLostErrContent.jsp',
		theme:'black'
    });
    $("body").css({overflow:"hidden"});//禁用滚动条
}

/**
 * 异地登陆
 */
function doubleLoginError(){
	win = $.nsWindow.open({
		title: '您的账户在异地登陆...',
		width: 305,
		height: 205,
		showControlBar:true,
		dataUrl: getRootPath()+'js/error/doubleLoginErrContent.jsp',
		theme:'black'
    });
    $("body").css({overflow:"hidden"});//禁用滚动条
}
/**
 * 没有权限
 */
function noPowerError(){
	win = $.nsWindow.open({
		title: '你没有足够的权限...',
		width: 305,
		height: 205,
		showControlBar:true,
		dataUrl: getRootPath()+'js/error/noPowerErrContent.jsp',
		theme:'black'
	});
	$("body").css({overflow:"hidden"});//禁用滚动条
}

/**
 * 显示错误消息
 * @param msg
 */
function showErrMsgWin(msg){
	win = $.nsWindow.open({
		title: '操作提示',
		width: 305,
		height: 205,
		showControlBar:true,
		closable:true,
		dataUrl: getRootPath()+'js/error/showErrContent.jsp',
		data:msg,
		theme:'black'
    });
    $("body").css({overflow:"hidden"});//禁用滚动条
}
/**
 * 显示成功消息
 * @param msg
 */
function showSuccessMsgWin(msg){
	win = $.nsWindow.open({
		title: '操作提示',
		width: 305,
		height: 205,
		showControlBar:true,
		closable:true,
		dataUrl: getRootPath()+'js/error/showSuccessContent.jsp',
		data:msg,
		theme:'black'
    });
    $("body").css({overflow:"hidden"});//禁用滚动条
}


/**
 * 重新登陆
 */
function login(){
	$.ajax({
		type : "get",
		datatype : "json",
		url : "../userlg/relogin",
		success : function(data) {
			var gbRst = JSON.parse(data);
			if(gbRst.state==0){
				$('#main').attr('src',$('#main').attr('src'));
				$("body").css({overflow:"auto"});//释放滚动条
				window.location.reload();
				win.close();
			}if(gbRst.state==1){
				alert("抱歉，会话已过期，无法自动重新登陆");
				gblogin();
			}else{
				checkStateCommon(gbRst.state);
			}
		}
	});
}

function modifyPassword(){
	alert("努力完善中...");
}


/**
 * 跳转到登陆页
 */
function gblogin(){
	win.close();
	window.location.href= getRootPath()+"html/login.html";
}

/*
 * 刷新页面
 */
function fresh(){
	window.location.reload();
}

/**
 * 关闭窗口
 */
function colseWin(){
	win.close();
	$("body").css({overflow:"auto"});//释放滚动条
}